<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="买家ID" prop="userId">
        <el-input
          v-model="queryParams.userId"
          placeholder="请输入买家ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="买家账号" prop="userAccount" label-width="120px">
        <el-input
          v-model="queryParams.userAccount"
          placeholder="请输入买家账号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="卖家ID" prop="salerId" label-width="120px">
        <el-input
          v-model="queryParams.salerId"
          placeholder="请输入卖家ID"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="卖家账号" prop="salerAccount" label-width="120px">
        <el-input
          v-model="queryParams.salerAccount"
          placeholder="卖家账号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="下单时间" label-width="120px">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="orderList" type="expand">
      <el-table-column label="买家ID" align="center" prop="userId" width="150"/>
      <el-table-column label="买家账号" align="center" prop="userAccount" width="180"/>
      <el-table-column label="商品ID" align="center" prop="goodsId" width="150"/>
      <el-table-column label="商品信息" align="center" width="400px">
        <template slot-scope="scope">
          <el-image
            :src="requestUrl + scope.row.mainImg"
            style="
              width: 140px;
              height: 100px;
              float: center;
              display: inline-block;
            "
          />
          <span
            style="
              float: center;
              vertical-align: middle;
              display: inline-block;
              line-height: 100px;
            "
          >{{ scope.row.goodsName }}</span
          >
        </template>
      </el-table-column>
      <el-table-column label="商品编号" align="center" prop="serialNum" width="180"/>
      <el-table-column label="购买价格" align="center" prop="price" width="180"/>
      <el-table-column label="卖家ID" align="center" prop="salerId" width="150"/>
      <el-table-column label="卖家账号" align="center" prop="salerAccount" width="180"/>
      <el-table-column label="下单时间" align="center" prop="createTime" width="180"/>
      <el-table-column label="上架时间" align="center" prop="resaleTime" width="180"/>
      <el-table-column label="转售时间" align="center" prop="finishResaleTime" width="180"/>
      <el-table-column label="订单状态" align="center" prop="goodsStatus">
        <template slot-scope="scope">
          <span v-if="scope.row.goodsStatus === 0">仓库中</span>
          <span v-if="scope.row.goodsStatus === 1">转售中</span>
          <span v-if="scope.row.goodsStatus === 2">已转售</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
  import { listOrderInfo} from '@/api/admin/activityGoodsInfo'

  export default {
    name: 'resaleOrder',
    data() {
      return {
        requestUrl: this.$img.requestUrl,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 订单表格数据
        orderList: [],
        // 弹出层标题
        title: '',
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          orderType:1,
          goodsStatus:2
        },
        dateRange:[]
      }
    },
    created() {
    this.getList();
    },

    methods: {
      /** 查询订单列表 */
      getList() {
        this.loading = true
        listOrderInfo(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.orderList = response.rows
          this.total = response.total
          this.loading = false
        })
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1
        this.getList()
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.dateRange = [];
        this.resetForm('queryForm')
        this.handleQuery()
      }


    }
  }
</script>
